from django.contrib.auth.models import User
from django.db import models

# Create your models here.
import usermanage.models


class GroupInfo(models.Model):
    visibilityChoices = [
        (1, '完全公开'),
        (2, '登陆可见'),
        (3, '仅成员可见'),
    ]
    applyPermChoices =[
        (1, '任何人可加入'),
        (2, '申请加入'),
        (3, '禁止加入'),
    ]
    founder = models.ForeignKey(User, on_delete=models.CASCADE)
    maxPerson = models.IntegerField(default=100)
    visibility = models.IntegerField(choices=visibilityChoices)
    applyPermission = models.IntegerField(choices=applyPermChoices)
    createTime = models.DateTimeField(auto_now_add=True)
    groupName = models.CharField(max_length=128)
    groupIntro = models.CharField(max_length=512, blank=True, null=True)
    # TODO:头衔名称自定义


class GroupUsers(models.Model):
    statusChoices = [
        (1, '已加入'),
        (2, '申请中'),
        (3, '被拒绝'),
    ]
    group = models.ForeignKey(GroupInfo, on_delete=models.CASCADE)
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    isgroupadmin = models.BooleanField(default=False)
    status = models.IntegerField(choices=statusChoices,default=2)
    titleLevel = models.IntegerField(default=0)  # TODO:限制条件？
